package com.from.menlo.park.data;

import java.sql.Timestamp;
import java.util.Date;

public class Entry {
    private Location location;
    private Date time;
    private String note;
    private Tag[] tags;
    private String tagStr;
   
	private Mood[] moods;
    private String moodStr;
    private Photo[] photos;
    private boolean hasPhotos;
    
    public boolean isHasPhotos() {
		return hasPhotos;
	}
	public void setHasPhotos(boolean hasPhotos) {
		this.hasPhotos = hasPhotos;
	}
	private long id;
    
    
	public long getId() {
		return id;
	}
	public void setId(long id) {
		this.id = id;
	}
	public Photo[] getPhotos() {
		return photos;
	}
	public void setPhotos(Photo[] photos) {
		this.photos = photos;
	}
	public Location getLocation() {
		return location;
	}
	public void setLocation(Location location) {
		this.location = location;
	}
	public Date getTime() {
		return time;
	}
	public void setTime(Date time) {
		this.time = time;
	}
	public String getNote() {
		return note;
	}
	public void setNote(String note) {
		this.note = note;
	}
	public Tag[] getTags() {
		if ( tags == null && tagStr != null ){
			String[] tagsStr = tagStr.split("\\|");
			tags = new Tag[tagsStr.length];
			for( int i = 0; i < tags.length; i++ ){
				try{
					tags[i] = Tag.fromId(Integer.parseInt(tagsStr[i]));
				}catch (Exception e) { 
				}
			}
		}
		return tags;
	}
	public void setTags(Tag[] tags) {
		this.tags = tags;
	}
	public Mood[] getMoods() {
		if ( moods == null && moodStr != null ){
			String[] moodsStr = moodStr.split("\\|");
			moods = new Mood[moodsStr.length];
			for( int i = 0; i < moods.length; i++ ){
				try{
				    moods[i] = Mood.fromId(Integer.parseInt(moodsStr[i]));
				}catch (Exception e) { 
				}
			}
		}
		return moods;
	}
	public void setMoods(Mood[] moods) {
		this.moods = moods;
	}
	 public String getTagStr() {
		if ( tagStr == null && tags != null && tags.length > 0 ){
			tagStr = tags[0].getValue() + "";
			if ( tags.length > 1 ){
				for ( int i = 1 ; i < tags.length; i ++ ){
					tagStr = tagStr + "|" +  tags[i].getValue();
				}
			}
		}
		return tagStr;
     }
		public void setTagStr(String tagStr) {
			this.tagStr = tagStr;
		}
		public String getMoodStr() {
			if ( moodStr == null && moods != null && moods.length > 0 ){
				moodStr = moods[0].getValue() + "";
				if ( moods.length > 1 ){
					for ( int i = 1 ; i < moods.length; i ++ ){
						moodStr = moodStr + "|" +  moods[i].getValue();
					}
				}
			}
			return moodStr;
		}
		public void setMoodStr(String moodStr) {
			this.moodStr = moodStr;
		}
}
